<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONArray"%>
<%@page import="net.vinote.smart.platform.comm.StringFunction"%>
<%@page import="net.vinote.smart.platform.comm.PlatformConst"%>
<%@page import="net.vinote.smart.platform.service.bean.AppItem"%>
<%@page import="net.vinote.smart.platform.service.bean.AppInfo"%>
<%@page import="net.vinote.smart.platform.exception.PlatformException"%>
<%@page import="net.vinote.smart.platform.service.bean.CodeLibrary"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/comm/begin.jsp"%>
<%
	String subject=request.getParameter("subject");
	List<CodeLibrary> list =CurUser.getSubjectList();
	JSONArray array=new JSONArray();
%>
<div id="global-nav">
	<div
		style="float: right; font-size: 12px; color: #fff; margin: 5px 10px 0 0">
		<%=CurUser.getUserName()%>
		&nbsp;&nbsp;&nbsp;<a href="logoff" target="_parent">注销</a>&nbsp;
		<%
			if(list.size()>0){
			if(subject==null){
				subject=list.get(0).getItemNo();
			}
			
			for(CodeLibrary lib:list){
				JSONObject json=new JSONObject();
				json.put("id", lib.getItemNo());
				json.put("text", lib.getItemName());
				if(lib.getItemNo().equals(subject)){
					json.put("selected", true);
				}
				array.put(json);
			}
		%>
		<select id="cc" class="easyui-combobox" name="state"
			style="width: 100px;"
			data-options="required:true,editable:false,panelHeight:'auto'">
		</select>
		<%
			}else{
				throw new PlatformException("对不起,您对本系统暂无使用权限!可联系管理员");
			}
		%>
	</div>
	<ul class="links appItems">
		<%
			List<AppInfo> appList=CurUser.getAppInfoBySubject(subject);
			for (AppInfo app : appList) {
				List<AppItem> itemList=CurUser.getAppItemByAppID(app.getAppID());
		%>
		<li <%=itemList.size()>0?" class='dropdown'":""%>><a
			href="javascript:void(0);"
			<%=StringFunction.nullToBlank(app.getUrl()).length()>0?("onclick=\"AWE.openTab('APP_"
					+ app.getAppID()
					+ "','"
					+ app.getAppName()
					+ "','"
					+ app.getUrl()
					+ "')\""):""%>><%=app.getAppName()%></a>
			<%
				if (itemList.size() > 0) {
			%><ul>
				<%
					for (AppItem item : itemList) {
						String triggerMode =item.getTriggerMode();// b.getAttribute("TriggerMode");
				%>
				<li><a href="javascript:void();"
					onclick="<%="javascript".equals(triggerMode) ? item.getUrl()
									: ("openTab".equals(triggerMode) ? "AWE.openTab('"
											+ app.getAppID()
											+ item.getItemID()
											+ "','"
											+ item.getItemName()
											+ "','"
											+ item.getUrl()
											+ "')"
											: ("openPage".equals(triggerMode) ? "DWControl.OpenComp('"
													+ item.getUrl()
													+ "')"
													: ""))%>"><%=item.getItemName()%></a></li>
				<%
					}
				%>
			</ul> <%
 	}
 %></li>
		<%
			}
		%>
	</ul>
</div>
<div class='easyui-layout' data-options="fit:true,border:false" style="">
	<div data-options="region:'center',border:false"
		style="padding-bottom: 54px">
		<div class='easyui-tabs' fit='true'>
			<%
				if(PlatformConst.Yes==SRE.getSystemParameter().getOpenWorkBench()){
			%>
			<div title="首页" style="padding: 20px;"
				data-options="href:'frame/workbench.jsp?subject=<%=subject%>'"></div>
			<%
				}
			%>
		</div>
		<div style="text-align: center; border: 0px;">
			<div id="clock" style="float: right; margin-right: 5px;"></div>
			zhengjunweimail@163.com
		</div>
	</div>
</div>
<script>
$(function(){
	$('#cc').combobox(
			{valueField: 'id',
				textField: 'text',data:<%=array.toString()%>,
				onSelect : function(record) {
					DWControl.OpenComp("frame/main_page.jsp", "subject="
							+ record.id);
				}
			});
	$('.combo-text').click(function(){
		$(this).parent().parent().children('.easyui-combobox').combobox("showPanel");
	});
});
function changeClock()
{
	var d = new Date();
	document.getElementById("clock").innerHTML = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
}
window.setInterval(changeClock, 1000);
</script>
<%@include file="/comm/end.jsp"%>
